#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 1e9+7;
const int MAXN = 1000005 ;
LL N, K;

LL cal(LL n, LL k){
    LL i = 3, ans = 0;
    LL mu = min(n, k);
    while(i <= mu) {
        LL v = n / i;
        LL last = n / v;
        if(last > mu) {ans = (ans + v*(mu-i+1))%mod; break;}
        ans += v * (last - i + 1);
        ans %= mod;
        i = last + 1;
    }
    return ans;
}

LL mulEx(LL a , LL b , LL Mod) {///logn快速乘
    if(!a) return 0 ;
    LL ans(0) ;
    while(b)
    {
        if(b & 1) ans = (ans + a) % Mod;
        a <<= 1 ;
        a %= Mod ;
        b >>= 1 ;
    }
    return ans ;
}

LL powEx(LL base , LL n , LL Mod)
{///快速幂
    LL ans(1) ;
    while(n)
    {
        if(n & 1) ans = mulEx(ans , base , Mod) ;
        base = mulEx(base , base , Mod) ;
        n >>= 1 ;
    }
    return ans ;
}

bool check(LL a , LL d , LL n)
{
    if(n == a) return true ;
    while(~d & 1) d >>= 1 ;
    LL t = powEx(a , d , n) ;
    while(d < n - 1 && t != 1 && t != n - 1)
    {
        t = mulEx(t , t , n) ;
        d <<= 1 ;
    }
    return (d & 1) || t == n - 1 ;
}

bool isP(LL n)
{ ///判断大数是否是质数
    if(n == 2) return true ;
    if(n < 2 || 0 == (n & 1)) return false ;
    static int p[5] = {2 , 3 , 7 , 61 , 24251} ;
    for(int i = 0 ; i < 5 ; ++ i) if(!check(p[i] , n - 1 , n)) return false ;
    return true ;
}

LL gcd(LL a , LL b)
{
    if(a < 0) return gcd(-a , b) ;
    return b ? gcd(b , a - b * (a / b)) : a ;
}

LL Pollard_rho(LL n , LL c)
{///大数分解质因数
    LL i = 1 , k = 2 , x = rand() % n , y = x ;
    while(true)
    {
        x = (mulEx(x , x , n) + c) % n ;
        LL d = gcd(y - x , n) ;
        if(d != 1 && d != n) return d ;
        if(y == x) return n ;
        if(++ i == k)
        {
            y = x ;
            k <<= 1 ;
        }
    }
}

LL Fac[MAXN] , factCnt ;
///Fac存的是质因子,大小不一定按照顺序,有重复
void factorization(LL n)
{
    if(isP(n))
    {
        Fac[factCnt++] = n ;
        return ;
    }
    LL p(n) ;
    while(p >= n) p = Pollard_rho(p , rand() % (n - 1) + 1) ;
    factorization(p) ;
    factorization(n / p) ;
}

map<LL , LL> factMap ;
///遍历map的first表示因子,second表示次数

void getFactor(LL x)
{///不用判断是否是质数,但是比较费时间
    /**因此最好先判断一下是否是质数**/
    srand(time(0)) ;
    factCnt = 0 ;
    factMap.clear() ;
    factorization(x) ;
    for(int i = 0; i < factCnt; ++i) ++ factMap[Fac[i]] ;
}
int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    cin >> N >> K;
    LL ans;
    if(K <=2 || N==1) ans = (N%mod *K%mod)%mod;
    else{
        ans = (2*N + K-2)%mod;
        LL c = cal(N-1, K);
//        c = (c - (N-1)/2 + (N-1))%mod;
        ans = (ans + 2*c)%mod;
        getFactor(N);

        LL n = N;
        LL t2 = factMap[2];
        LL cnt = 0;
        set<LL> s;
        for (auto &it:factMap){
            LL f = it.first, times = it.second;

            for (int i = 0; i < times; ++i) {
                if(f >=3 && n<=K) s.insert(f);
//                if(f<=K && f!=2)++cnt;
                n/=f;
//                if(n!=1 && n<=K) ++cnt;
                if(n >=3 && n<=K) s.insert(n);
            }
        }

        if(t2) cnt += t2-1;
        cnt += s.size();
        ans = (ans + cnt)%mod;
    }

    cout << ans;
    return 0;
}